<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Yy</title>
    <style>
        img {
            height: 120px;
            width: 240px;
        }
        
        .swiper {
            width: 240px;
            height: 120px;
            overflow: hidden;
            position: relative;
        }
        
        .images-container {
            width: 1920px;
            height: 120px;
            display: flex;
            transition: transform 0.5s;
        }
        
        .images-container img {
            width: 240px;
            height: 120px;
        }
        
        .number-list {
            position: absolute;
            bottom: 0;
        }
    </style>
</head>

<body>
    <!-- 1. 实现一个点击数字列表，切换图片的效果。 -->
    <div>
        <img src="images/a.jpg" alt="">
    </div>
    <button>1</button>
    <button>2</button>
    <button>3</button>
    <!-- 2.实现一个轮播图效果 -->
    <div class="swiper">
        <div class="images-container">
            <img src="images/a.jpg" alt="">
            <img src="images/b.jpg" alt="">
            <img src="images/c.jpg" alt="">
        </div>
        <div class="number-list">
            <button>1</button>
            <button>2</button>
            <button>3</button>
        </div>
    </div>
    <script>
        // 1. 实现一个点击数字列表，切换图片的效果。
        let img = document.querySelector("img");
        let imagesSrcList = ["images/a.jpg", "images/b.jpg", "images/c.jpg"];
        let btns = document.querySelectorAll("button");
        for (let i in btns) {
            btns[i].onclick = function() {
                img.src = imagesSrcList[i];
            }
        }
        // 2.实现一个轮播图效果
        let btnList = document.querySelectorAll(".number-list button");
        let container = document.querySelector(".images-container");
        for (let i in btnList) {
            btnList[i].onclick = function() {
                container.style.transform = `translate(${-240 * i}px)`;
            }
        }
    </script>
</body>

</html>